package com.example.exception;

import lombok.Getter;
import lombok.Setter;

/**
 * 自定义业务异常类
 * 用于在业务逻辑中主动抛出异常
 */
@Setter
@Getter
public class BusinessException extends RuntimeException {
    private Integer code;
    private String msg;

    /**
     * 构造函数
     *
     * @param message 异常消息
     */
    public BusinessException(String message) {
        super(message);
        this.msg = message;
        this.code = 500; // 默认错误码
    }

    /**
     * 构造函数
     *
     * @param code    错误码
     * @param message 异常消息
     */
    public BusinessException(Integer code, String message) {
        super(message);
        this.code = code;
        this.msg = message;
    }

}